package com.inmaytide.website.mapper.system;

import com.inmaytide.website.domain.entities.system.SysRole;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SysRoleMapper extends Mapper<SysRole> {

    @Select({
            "select a.* from sys_role a ",
            "left join sys_user_role b on a.id = b.role_id ",
            "left join sys_user c on c.id = b.user_id ",
            "where c.id = #{uid}"
    })
    @Results({
            @Result(column = "role_name", property = "roleName"),
            @Result(column = "role_code", property = "roleCode"),
            @Result(column = "role_desc", property = "roleDesc")
    })
    public List<SysRole> findByUser(@Param("uid") Long uid);

}